package org.reyton.service.impl;

import org.reyton.dao.BizClaimVoucherDao;
import org.reyton.dao.BizClaimVoucherDetailDao;
import org.reyton.entity.BizClaimVoucher;
import org.reyton.entity.BizClaimVoucherDetail;
import org.reyton.service.BizClaimVoucherDetailService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * 报销单明细实现类
 * Created by reyton on 16-12-2.
 */

@Service("bizClaimVoucherDetailService")
public class BizClaimVoucherDetailServiceImpl implements BizClaimVoucherDetailService {
    @Resource(name = "bizClaimVoucherDetailDao")
    private BizClaimVoucherDetailDao bizClaimVoucherDetailDao;
    @Resource(name = "bizClaimVoucherDao")
    public BizClaimVoucherDao bizClaimVoucherDao;

    @Override
    @Transactional(propagation = Propagation.REQUIRED,
            isolation = Isolation.DEFAULT,
            rollbackFor = RuntimeException.class)
    public void saveDetail(BizClaimVoucherDetail bizClaimVoucherDetail) {
        bizClaimVoucherDetailDao.save(bizClaimVoucherDetail);
    }

    @Override
    public List<BizClaimVoucherDetail> findDetails(BizClaimVoucher bizClaimVoucher) {
        return bizClaimVoucherDetailDao.find(bizClaimVoucher);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED,
            isolation = Isolation.DEFAULT,
            rollbackFor = RuntimeException.class)
    public void deleteDetails(BizClaimVoucherDetail bizClaimVoucherDetail) {
        bizClaimVoucherDetailDao.delete(bizClaimVoucherDetail);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED,
            isolation = Isolation.DEFAULT,
            rollbackFor = RuntimeException.class)
    public void editDetails(BizClaimVoucherDetail bizClaimVoucherDetail) {
        bizClaimVoucherDetailDao.update(bizClaimVoucherDetail);
    }

    public void setBizClaimVoucherDao(BizClaimVoucherDao bizClaimVoucherDao) {
        this.bizClaimVoucherDao = bizClaimVoucherDao;
    }

    public void setBizClaimVoucherDetailDao(BizClaimVoucherDetailDao bizClaimVoucherDetailDao) {
        this.bizClaimVoucherDetailDao = bizClaimVoucherDetailDao;
    }

}
